<template>
  <div id="app">
    <div class="header">选择课程</div>
    <div class="course-list">
      <div class="course-item" v-for="course in courses" :key="course.id">
        <img class="course-img" :src="course.img" alt="" />
        <div class="course-info">
          <h3>{{ course.name }}</h3>
          <p>培训周期：{{ course.period }}</p>
          <p>授课方式：{{ course.method }}</p>
          <p>本月报名：{{ course.signUp }}人</p>
          <div class="price">
            <span class="current">￥{{ course.price }}</span>
            <span class="origin">￥{{ course.originPrice }}</span>
            <button class="btn" @click="signUp(course)">立即报名</button>
          </div>
        </div>
      </div>
    </div>
    <!-- 底部导航 -->
    <div class="tabbar">
      <div
              class="tab-item"
              v-for="tab in tabs"
              :key="tab.name"
              :class="{ active: currentTab === tab.name }"
              @click="currentTab = tab.name"
      >
        <img :src="currentTab === tab.name ? tab.iconActive : tab.icon" alt="">
        <span>{{ tab.label }}</span>
      </div>
    </div>
  </div>
</template>

<script>
    export default {
        name: 'App',
        data() {
            return {
                currentTab: '首页',
                tabs: [
                    {
                        name: '首页',
                        label: '首页',
                        icon: 'https://via.placeholder.com/20?text=H',
                        iconActive: 'https://via.placeholder.com/20/1890ff/fff?text=H'
                    },
                    {
                        name: '课程管理',
                        label: '课程管理',
                        icon: 'https://via.placeholder.com/20?text=K',
                        iconActive: 'https://via.placeholder.com/20/1890ff/fff?text=K'
                    },
                    {
                        name: '个人中心',
                        label: '个人中心',
                        icon: 'https://via.placeholder.com/20?text=P',
                        iconActive: 'https://via.placeholder.com/20/1890ff/fff?text=P'
                    }
                ],
                courses: [
                    {
                        id: 1,
                        name: '插画高级班培训',
                        img: 'https://via.placeholder.com/80',
                        period: '5个月',
                        method: '线上',
                        signUp: 648,
                        price: 6856,
                        originPrice: 7888
                    },
                    {
                        id: 2,
                        name: 'Python',
                        img: 'https://via.placeholder.com/80',
                        period: '1年',
                        method: '线上',
                        signUp: 785,
                        price: 8880,
                        originPrice: 9680
                    },
                    {
                        id: 3,
                        name: '日语教学',
                        img: 'https://via.placeholder.com/80',
                        period: '1年',
                        method: '线上',
                        signUp: 611,
                        price: 8380,
                        originPrice: 9080
                    },
                    {
                        id: 4,
                        name: '影视后期制作',
                        img: 'https://via.placeholder.com/80',
                        period: '6个月',
                        method: '线上',
                        signUp: 1022,
                        price: 7980,
                        originPrice: 8280
                    }
                ]
            };
        },
    };
</script>


<style scoped>
  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  .header {
    padding: 10px;
    text-align: center;
    font-weight: bold;
    border-bottom: 1px solid #f0f0f0;
    font-size: 16px;
    flex-shrink: 0;
  }
  .course-list {
    padding: 10px;
    flex: 1;
    overflow-y: auto;
  }
  .course-item {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    align-items: center;
  }
  .course-img {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    margin-right: 10px;
    object-fit: cover;
  }
  .course-info {
    flex: 1;
  }
  .course-info h3 {
    margin: 0;
    font-size: 15px;
  }
  .course-info p {
    margin: 2px 0;
    font-size: 12px;
    color: #999;
  }
  .price {
    display: flex;
    align-items: center;
    margin-top: 4px;
  }
  .current {
    color: red;
    font-size: 14px;
    margin-right: 6px;
  }
  .origin {
    text-decoration: line-through;
    color: #aaa;
    font-size: 12px;
    margin-right: auto;
  }
  .btn {
    background: #fff0f0;
    color: red;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
  }
  .btn:active {
    background: #ffdcdc;
  }
  /* 底部导航栏 */
  .tabbar {
    display: flex;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    height: 50px;
    flex-shrink: 0;
  }
  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
  }
  .tab-item.active {
    color: #1890ff;
  }
  .tab-item img {
    width: 20px;
    height: 20px;
    margin-bottom: 2px;
  }
</style>


